import request from "@/utils/request";
import type {
  RiderLoginData,
  RiderRegisterData,
  LocationUpdateData,
  WorkStatus,
  TimeRange,
  VehicleType
} from "@/types/rider";

const riderApi = {
  // 骑手登录
  login: (data: RiderLoginData) =>
    request.post("/api/auth/login", data),

  // 更新工作状态
  updateWorkStatus: (status: WorkStatus) =>
    request.put("/api/rider/status", { workStatus: status }),

  // 获取骑手当前状态
  getCurrentStatus: () =>
    request.get("/api/rider/status"),

  // 送达订单
  deliverOrder: (orderId: string) =>
    request.post(`/orders/${orderId}/delivered`),

  // 更新骑手位置
  updateLocation: (data: LocationUpdateData) =>
    request.put("/api/rider/location", data),

  // 注册骑手
  register: (data: RiderRegisterData) =>
    request.post("/api/rider/register", data),

  // 取餐
  pickupOrder: (orderId: string) =>
    request.post(`/orders/${orderId}/pickup`),

  // 接单
  acceptOrder: (orderId: string) =>
    request.post(`/api/rider/orders/${orderId}/accept`),

  // 获取统计数据
  getStats: (period: TimeRange) =>
    request.get("/api/rider/stats", {
      params: { period },
    }),

  // 获取骑手已接订单列表
  getAcceptedOrders: () => 
    request.get("/api/rider/orders"),

  // 获取可接单列表
  getAvailableOrders: () => 
    request.get("/api/rider/orders/available"),
};

export { riderApi };
